The following modifiers customize the behavior and appearance of TextField
components. These allow you to control keyboard behavior, input handling, and submission logic.
onSubmit
Adds an action to perform when the user submits a value from the text field.
If provided as a function:
This is equivalent to:
You can explicitly define what kind of submission should trigger the action using the triggers
option:
SubmitTriggers
values:"text"
: Triggered by text input views like TextField
, SecureField
, etc."search"
: Triggered by search fields (e.g., those using the searchable
modifier).keyboardType
Specifies the type of keyboard to display when the text field is focused.
'default'
'numberPad'
'phonePad'
'namePhonePad'
'URL'
'decimalPad'
'asciiCapable'
'asciiCapableNumberPad'
'emailAddress'
'numbersAndPunctuation'
'twitter'
'webSearch'
autocorrectionDisabled
Controls whether the system autocorrection is enabled.
true
— autocorrection is disabled by default.textInputAutocapitalization
Sets how the text input system should automatically capitalize text.
"never"
– No capitalization."characters"
– All letters capitalized."sentences"
– First letter of each sentence capitalized."words"
– First letter of each word capitalized.submitScope
Prevents submission triggers from this view from propagating upward to parent views with submission handlers.
false
— submission actions bubble up by default.This ensures that onSubmit
handlers defined higher up in the view hierarchy won’t be called when this field is submitted.